//潜在客户
$(function () {
    var record_datagrid = $("#record_datagrid");

// 数据 表
    record_datagrid.datagrid({
        url: "/lostRecord/query.do",
        fitColumns: true, // 自适应列
        fit: true,
        striped: true,  // 斑马线
        pagination: true,
        rownumbers: true,
        pageSize: 10,
        pageNumber: 1,
        singleSelect: true, // 单选
        toolbar: "#record_toolbar",
        columns: [
            [
                {field: 'id', title: '编号', width: 80, sortable: true},
                {field: 'date', title: '日期', width: 80, sortable: true},
                {
                    field: 'client', title: '客户', width: 50,
                    formatter: function (value) {
                        return value ? value.name : "";
                    }
                },
                {
                    field: 'charger', title: '当时负责人', width: 50,
                    formatter: function (value) {
                        return value ? value.username : "";
                    }
                },
                {field: 'reason', title: '详细原因', width: 80}
            ]
        ]
    });

    var objMethod = {
        //刷新表单
        refresh: function () {
            record_datagrid.datagrid("reload");
        },
        //高级查询
        query: function () {
            var minDate = $("#minDate").textbox('getValue');
            var maxDate = $("#maxDate").textbox('getValue');
            var charger = $("#charger").textbox('getValue');
            var client = $("#client").textbox('getValue');
            record_datagrid.datagrid('load', {
                minDate: minDate,
                maxDate: maxDate,
                charger: charger,
                client: client
            });
        }
    };
    // 绑定事件
    $('a[data-cmd]').click(function () {
        objMethod[$(this).data('cmd')]();
    })
});

